﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAplicaciones1;



namespace interfaz
{
    public partial class FormReporteVentas : Form
    {
        private Sistema sistema;
        

        public FormReporteVentas()
       {
            InitializeComponent();
            sistema = Sistema.GetSistema();
          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double result = 0;
            try
            {
                lblError.Text = "";
                if (rbtnTotal.Checked)
                 result = sistema.calcularVentasTotal();                

                if (rbtnPeriodo.Checked)
                    result = sistema.calcularVentasPeriodo(dateTimePicker1.Value, dateTimePicker2.Value);
                
                lblResultado.Visible = true;
                txtResultado.Visible = true;
                txtResultado.Text = result.ToString();
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            FormMenu menu = new FormMenu();
            this.Visible = false;
            menu.ShowDialog();
           
        }

        private void fieldsControl(object sender, EventArgs e)
        {/*
            if (rbtnPeriodo.Checked)
            {
               dateTimePicker1.rea .ReadOnly = false;
                txtHasta.ReadOnly = false;
            }
            if (rbtnTotal.Checked)
            {
                txtDesde.ReadOnly = true;
                txtHasta.ReadOnly = true;
            }*/
        }

        private void FormReporteVentas_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
     
    }
}
